package com.google.code.afreechartapp.iris;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Spinner;
import com.google.code.afreechartapp.iris.R;

public class IRISConfig extends Activity {

    private Spinner mRangeAxisSpinner;
    private Spinner mDomainAxisSpinner;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.axis_config);

        mDomainAxisSpinner = (Spinner)findViewById(R.id.domain_axis_spinner);
        mRangeAxisSpinner = (Spinner)findViewById(R.id.range_axis_spinner);
        
        Intent intent = getIntent();
        mDomainAxisSpinner.setSelection(intent.getIntExtra(IRISDataViewer.DOMAIN_AXIS_TYPE_ID, -1));
        mRangeAxisSpinner.setSelection(intent.getIntExtra(IRISDataViewer.RANGE_AXIS_TYPE_ID, -1));
    }
    
    public void onOK(View view) {
        int domainAxisId = mDomainAxisSpinner.getSelectedItemPosition();
        int rangeAxisId = mRangeAxisSpinner.getSelectedItemPosition();
        
        Intent intent = new Intent();
        intent.putExtra(IRISDataViewer.DOMAIN_AXIS_TYPE_ID, domainAxisId);
        intent.putExtra(IRISDataViewer.RANGE_AXIS_TYPE_ID, rangeAxisId);
        setResult(RESULT_OK, intent);
        finish();
    }
}
